package com.crm.customers.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.crm.customers.dao.ContractDao;
import com.crm.customers.dao.CustomerCategoryDao;
import com.crm.customers.dao.CustomerContactsDao;
import com.crm.customers.dao.CustomerDao;
import com.crm.customers.dao.CustomerFilesDao;
import com.crm.customers.dao.CustomerQualificationItemDao;
import com.crm.customers.dao.CustomerQualificationUserDao;
import com.crm.customers.model.CustomerCategory;
import com.crm.customers.model.CustomerContacts;
import com.crm.customers.model.CustomerFiles;
import com.crm.customers.model.CustomerInfo;
import com.crm.customers.model.CustomerQualificationItem;
import com.crm.customers.model.CustomerQualificationUser;
import com.crm.customers.service.CustomerCategoryService;
import com.crm.customers.service.CustomerContactsService;
import com.crm.customers.service.CustomerInfoTempService;
import com.crm.customers.service.CustomerService;
import com.crm.sys.dao.FilesInfoDao;
import com.crm.sys.dao.SysDao;
import com.crm.sys.model.FilesInfo;
import com.crm.sys.model.Log;
import com.crm.user.dao.UserDao;
import com.crm.user.model.UserInfo;
import com.crm.util.Constants;
import com.crm.util.Pager;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;

@Service("customerService")
public class CustomerServiceImpl implements CustomerService {
	
	@Autowired
	private CustomerDao customerDao;
	
	@Autowired
	private CustomerContactsDao customerContactsDao;
	
	@Autowired
	private SysDao sysDao;
	
	@Autowired
	private CustomerFilesDao customerFilesDao;
	
	@Autowired
	private CustomerCategoryDao customerCategoryDao;
	
	@Autowired
	private FilesInfoDao filesInfoDao;
	
	@Autowired
	private UserDao userDao;
	
	@Autowired
	private ContractDao contractDao;
	
	@Autowired
	private CustomerContactsService customerContactsService;
	
	@Autowired
	private CustomerCategoryService customerCategoryService;
	
	@Autowired
	private CustomerInfoTempService customerInfoTempService;
	@Autowired
	private CustomerQualificationUserDao customerQualificationUserDao;
	@Autowired
	private CustomerQualificationItemDao customerQualificationItemDao;
	
	@Override
	//@Cacheable(value="baseCache",key="#cinfo.toString()")
	public Pager getCustomerInfoList(CustomerInfo cinfo, int pageNo,
			int pageSize) {
		
		/*
		 * 我要怎么实现这个功能呢？
		 * 因为是要共用的 所以条件一定要带有type
		 * 然后就是分库 要通过state
		 * 如果不是公共库的 uid也要知道
		 * 其他的就是条件了
		 * 等正式确认了然后再加
		 * */
		cinfo.setStartsize((pageNo-1)*pageSize);
		cinfo.setEndsize(pageSize);
		List<CustomerInfo>  list = customerDao.getCustomerInfoList(cinfo);
		/*
		 * 以后这里肯定要用到
		 * 联系人 需求 文件之类的，在这里先添加上了
		 * */
		for (CustomerInfo ci : list) {
			ci.setContactsItem(customerContactsDao.getCustomerContactsList(ci.getId()));
			//ci.setFilesItem(customerFilesDao.getcustomerfilelistbyid(ci.getId()));
			ci.setCategoryItem(customerCategoryDao.getCustomerCategoryListById(ci.getId()));
			//查询挂靠人员
			int size = customerDao.getQualificationCustomerSize(ci.getId());
			ci.setGaokaoQYSize(size);
		} 
		Pager  pager = new Pager();
		pager.setPageNo(pageNo);
		pager.setPageSize(pageSize);
		pager.setResultList(list);
		return pager;
	}
	

	@Override
	public CustomerInfo saveCustomerInfo(CustomerInfo cinfo) {
		if(cinfo.getId()!=null&&cinfo.getId()>0){
			//修改
			CustomerInfo cif = customerDao.getCustomerInfoById(cinfo.getId());
			if (cif.getState() == 4 && cif.getUid() == null) {
				/*Log log = new Log();
				log.setContentid(cinfo.getId());
				log.setCategory(cinfo.getType());
				if (cinfo.getState() == 1) {
					log.setDescription("调整成熟度为意向不明");
				} else if (cinfo.getState() == 2) {
					log.setDescription("调整成熟度为即将到期");
				} else if (cinfo.getState() == 3) {
					log.setDescription("调整成熟度为随时可挂");
				} else if (cinfo.getState() == 5) {
					log.setDescription("调整成熟度为有证就办");
				} else if (cinfo.getState() ==6) {
					log.setDescription("调整成熟度为将要聘证");
			     }
				 else if (cinfo.getState() ==7) {
						log.setDescription("调整成熟度为合作客户");
				 }
				log.setCreateuser(cinfo.getUid());
				log.setUid(cinfo.getUid());
				sysDao.insertLog(log);*/
			}
			cinfo =  customerDao.updateCustomerInfo(cinfo);
			if (cinfo.getType()!=null && cinfo.getType() == 0) {
				//修改个人联系人信息
				CustomerContacts ccon = new CustomerContacts();
				ccon.setCusid(cinfo.getId());
				ccon.setName(cinfo.getCname());
				ccon.setTel(cinfo.getTel());
				ccon.setPhone(cinfo.getPhone());
				ccon.setQq(cinfo.getQq());
				ccon.setWebchart(cinfo.getWebchart());
				ccon = customerContactsService.updateCustomerContacts(ccon);
			}
			return cinfo;
		}else{
			//新增
			cinfo  =  customerDao.insertCustomerInfo(cinfo);
			if(cinfo!=null&&cinfo.getId()!=null){
				
				if (cinfo.getType() == 1) {
					//新增企业，保存联系人
					CustomerContacts cc = new CustomerContacts();
					cc.setPhone(cinfo.getTel());
					cc.setName(cinfo.getName());
					cc.setCusid(cinfo.getId());
					customerContactsService.insertCustomerContacts(cc);
				} else if (cinfo.getType() == 0) {
					//新增个人，保存联系人
					CustomerContacts ccon = new CustomerContacts();
					ccon.setCusid(cinfo.getId());
					ccon.setName(cinfo.getCname());
					ccon.setTel(cinfo.getTel());
					ccon.setPhone(cinfo.getPhone());
					ccon.setQq(cinfo.getQq());
					ccon.setWebchart(cinfo.getWebchart());
					ccon = customerContactsService.insertCustomerContacts(ccon);
					if (cinfo.getCategory() != null && cinfo.getTypes() != null) {
						CustomerCategory ccat = new CustomerCategory();
						ccat.setCusid(cinfo.getId());
						ccat.setCategory(Integer.parseInt(cinfo.getCategory()));
						ccat.setTypes(Integer.parseInt(cinfo.getTypes()));
						ccat = customerCategoryService.insertCustomerCategory(ccat);
					}
					//因为增加了临时表,新增的时候会经过这里
					customerInfoTempService.bindCustomer(cinfo.getTel(), cinfo.getId(), cinfo.getUid());
				}
				
				/*List<CustomerContacts>  contactsList =  cinfo.getContactsItem();
				//保存客户联系人信息
				boolean result = false;
				for(CustomerContacts contacts:contactsList){
					contacts.setCusid(cinfo.getId());
					contacts.setIsmain(1);//设为主要联系人
					customerContactsDao.insertCustomerContacts(contacts);
					result = true;
					break;
				}*/
				//添加操作日志
				Log log = new Log();
				log.setContentid(cinfo.getId());
				if (cinfo.getType() == 0) {
					log.setCategory(Constants.LOGCATEGORY.ZERO);
				} else {
					log.setCategory(Constants.LOGCATEGORY.ONE);
				}
				log.setDescription("录入客户"+cinfo.getCname());
				log.setState(Constants.LOGSTATE.TWO);
				log.setCreateuser(cinfo.getCreateuser());
				log.setUid(cinfo.getCreateuser());
				log.setOid(cinfo.getCreateuser());
				sysDao.insertLog(log);
				return cinfo;
			}
		}
		
		return null;
	}

	

	@Override
	public CustomerInfo getCustomerInfoById(CustomerInfo cinfo) {
		CustomerInfo   customer =  customerDao.getCustomerInfoById(cinfo.getId());
		 if(customer!=null&&customer.getId()!=null){
			 Log log = new Log();
			 log.setContentid(cinfo.getId());
			 log.setCategory(Constants.LOGCATEGORY.ONE);
			 List<Log> logList =  sysDao.getLogList(log);
			 customer.setLogList(logList);
			 //当客户不属于公开库时 判断用户是否相等
			 if(customer.getState()!=4&&!customer.getUid().equals(cinfo.getCreateuser())){
				 return null;
			 }
			 //获取客户联系人信息
			 List<CustomerContacts> contacts = customerContactsDao.getCustomerContactsList(cinfo.getId());
			 customer.setContactsItem(contacts);
		 }
		 return customer;
	}

	@Override
	public CustomerInfo getCustomerInfoById(Long id) {
		 CustomerInfo   customer =  customerDao.getCustomerInfoById(id);
		 customer.setContactsItem(customerContactsDao.getCustomerContactsList(customer.getId()));
		 customer.setCategoryItem(customerCategoryDao.getCustomerCategoryListById(customer.getId()));
		//dd
		 //customerCategoryDao.getCustomerCategoryListById(customer.getId());
	
		  if(customer.getType()==1) {
				 CustomerInfo  param = new CustomerInfo();
				 param.setId(id);
				   //挂靠人员
				  customer.setGaokaoUser(customerDao.getQualificationUserList(param));
				  
		  }else {
			  CustomerInfo  param = new CustomerInfo();
				 param.setUid(id);
				 customer.setGaokaoQY(customerDao.getQualificationCustomerInfo(param));
		  }
		  
		 //获取文件列表（包括详细信息）
		 List<CustomerFiles> fileslist = customerFilesDao.getcustomerfilelistbyid(customer.getId());
		 FilesInfo fi = new FilesInfo();
		 for (CustomerFiles cf : fileslist) {
			 fi.setId(cf.getFileid());
			 cf.setFilesinfo(filesInfoDao.getFilesInfoByID(fi));
			 
			 Date date1 = DateUtil.parse(cf.getCreatedate());
			 
			 
			// Date date2 = DateUtil.parse(dateStr2);

			//相差一个月，31天
			long betweenDay = DateUtil.between(date1, new Date(), DateUnit.DAY);
			
			if(betweenDay>7) {
				cf.setUpdateState(0);
			}
		 }
		 customer.setFilesItem(fileslist);
		 return customer;
	}
 
	@Override
	//@Cacheable(value="cacheTestOne")
	public List<CustomerInfo> getCustomerByKeyWord(CustomerInfo cinfo, int pageNo, int pageSize) {
		cinfo.setStartsize((pageNo-1)*pageSize);
		cinfo.setEndsize(pageSize);
		List<CustomerInfo>  list = customerDao.getCustomerByKeyWord(cinfo);
		/*
		 * 以后这里肯定要用到
		 * 联系人 需求 文件之类的，在这里先添加上了
		 * */
		for (CustomerInfo ci : list) {
			ci.setContactsItem(customerContactsDao.getCustomerContactsList(ci.getId()));
			//ci.setFilesItem(customerFilesDao.getcustomerfilelistbyid(ci.getId()));
			ci.setCategoryItem(customerCategoryDao.getCustomerCategoryListById(ci.getId()));
			if (ci.getType() == 0) {
				ci.setContractItem(contractDao.selecByCusid(ci.getId()));
			}
		} 
		return list;
	}

	@Override
	public int updateCustomerState(CustomerInfo cinfo, Log log) {
		
		//添加操作日志
		sysDao.insertLog(log);
		return customerDao.updateCustomerState(cinfo);
	}

	@Override
	public int updateCustomerName(CustomerInfo cinfo) {
		return customerDao.updateCustomerName(cinfo);
	}

	@Override
	public int getCustomerInfoVerifyCount(CustomerInfo info) {
		return customerDao.getCustomerInfoVerifyCount(info);
	}


	@Override
	public List<CustomerInfo> getCustomerInfoListByTypes(int type, Long id,
			int pageSize, int pageNo) {
		//定义好对象
		List<CustomerInfo> cuslist = new ArrayList<CustomerInfo>();
		CustomerInfo ci = new CustomerInfo();
		ci.setCreateuser(id);
		ci.setStartsize((pageNo-1)*pageSize);
		ci.setEndsize(pageSize);
		if (type == 1) {
			//录入客户
			//数据库中，log表和info表中的客户和简历的表示数字不一样，一个是0客户，1简历一个是0简历，1客户
			ci.setType(1);
			cuslist = customerDao.getBookingCustomerInfoList(ci);
		} else if (type == 2) {
			//录入简历
			ci.setType(0);
			cuslist = customerDao.getBookingCustomerInfoList(ci);
		} else if (type == 3) {
			//今日联系
			ci.setState(2);
			cuslist = customerDao.getLXCustomerInfoList(ci);
		} else {
			//明日预约
			ci.setState(0);
			cuslist = customerDao.getLXCustomerInfoList(ci);
		}
		return cuslist;
	}


	@Override
	public int updateCustomerCategory(CustomerInfo info) {
		
		//要先根据客户id获取到所有的category列表
		List<CustomerCategory> list = customerCategoryDao.getCustomerCategoryListById(info.getId());
		StringBuffer sb = new StringBuffer();
		for (CustomerCategory cc : list) {
			sb.append(cc.getCategory()+",");
		}
		System.out.println(sb.toString());
		info.setCategory(sb.toString());
		return customerDao.updateCustomerCategory(info);
	}


	@Override
	public List<CustomerInfo> transformlist(CustomerInfo info,int pageNo,int pageSize) {
		
		List<CustomerInfo> list = customerDao.transformlist(info);
		/*for (CustomerInfo ci : list) {
			ci.setContactsItem(customerContactsDao.getCustomerContactsList(ci.getId()));
			ci.setFilesItem(customerFilesDao.getcustomerfilelistbyid(ci.getId()));
			ci.setCategoryItem(customerCategoryDao.getCustomerCategoryListById(ci.getId()));
		}*/
		return list;
	}


	@Override
	public CustomerInfo updatecustomertel(Long cuconid,Long ciid) {
		//根据联系记录表的id获取到客户的id
		List<CustomerContacts> clist = customerContactsDao.getcustconlistByid(cuconid);
		CustomerInfo ci = new CustomerInfo();
		ci.setId(ciid);
		String sb = "";
		for (CustomerContacts cc : clist) {
			
			if (cc.getTel() != null) {
				sb+=cc.getTel()+",";
			} else if (cc.getPhone() != null) {
				sb+=cc.getPhone()+",";
			}
		}
		ci.setTel(sb);
		customerDao.updateCustomerInfo(ci);
		return ci;
	}


	@Override
	public CustomerInfo updatecustomercategory(Long cucatid,Long ciid) {
		List<CustomerCategory> clist = customerCategoryDao.getcustcatlistByid(cucatid);
		CustomerInfo ci = new CustomerInfo();
		ci.setId(ciid);
		String sb = "";
		for (CustomerCategory cc : clist) {
			
			if (cc.getCategory() != null) {
				sb+=cc.getCategory()+",";
			} 
		}
		ci.setCategory(sb);
		customerDao.updateCustomerInfo(ci);
		return ci;
	}


	@Override
	public CustomerInfo updatecustomeruid(Long uid, Long oid, Long cusid,Long infoid,int type) {
		CustomerInfo ci = new CustomerInfo();
		ci.setId(cusid);
		ci.setUid(oid);
		ci = customerDao.updateCustomerInfo(ci);
		ci = customerDao.getCustomerInfoById(cusid);
		if (type < 0 ) {
			type = ci.getType();
		}
		//添加记录
		Log log = new Log();
		log.setContentid(ci.getId());
		if (type == 0) {
			log.setCategory(Constants.LOGCATEGORY.ZERO);
		} else {
			log.setCategory(Constants.LOGCATEGORY.ONE);
		}
		//设置为分配
		log.setState(Constants.LOGSTATE.FIVE);
		log.setOid(oid);
		UserInfo ui= new UserInfo();
		ui.setUid(oid);
		ui = userDao.getUserInfo(ui);
		log.setDescription("分配客户"+ ci.getCname() +"给"+ui.getName());
		log.setCreateuser(infoid);
		log.setUid(infoid);
		sysDao.insertLog(log);
		return ci;
	}


	@Override
	public int transformcustomerall(CustomerInfo info) {
		//转移所有 然后要把记录存到log中
		return customerDao.transCustomerAll(info);
	}


	@Override
	public int getCustomerInfoTotalSizeByParams(CustomerInfo info) {
		return customerDao.getCustomerInfoTotalSizeByParams(info);
	}


	@Override
	public void delCustomerInfo(CustomerInfo info) {
		 customerDao.updateCustomerInfo(info);
	}


	@Override
	public Pager getContractCustomerList(CustomerInfo info,int pageNo,int pageSize) {
		info.setStartsize((pageNo-1)*pageSize);
		info.setEndsize(pageSize);
		List<CustomerInfo>  list = customerDao.getContractCustomerList(info);
		Pager  pager = new Pager();
		pager.setPageNo(pageNo);
		pager.setPageSize(pageSize);
		pager.setResultList(list);
		return pager;
	}


	@Override
	public int getResourceCount(CustomerInfo info) {
		return customerDao.getResourceCount(info);
	}


	@Override
	public CustomerInfo getCustomerInfoById1(CustomerInfo cinfo) {
		CustomerInfo   customer =  customerDao.getCustomerInfoById(cinfo.getId());
		 if(customer!=null&&customer.getId()!=null){
			 Log log = new Log();
			 log.setContentid(cinfo.getId());
			 log.setCategory(Constants.LOGCATEGORY.ONE);
			 List<Log> logList =  sysDao.getLogList(log);
			 customer.setLogList(logList);
			 //获取客户联系人信息
			 List<CustomerContacts> contacts = customerContactsDao.getCustomerContactsList(cinfo.getId());
			 customer.setContactsItem(contacts);
		 }
		 return customer;
	}

	 /**
	  * 获取客户基本信息详情
	  * @param cinfo
	  * @return
	  */
	 public CustomerInfo getCustomerInfoConttactsById(CustomerInfo cinfo) {
		 CustomerInfo   customer =  customerDao.getCustomerInfoById(cinfo.getId());
		 if(customer!=null&&customer.getId()!=null){
			 //获取客户联系人信息
			 List<CustomerContacts> contacts = customerContactsDao.getCustomerContactsList(cinfo.getId());
			 customer.setContactsItem(contacts);
		 }
		 return customer;
	 }
	 
	

	@Override
	public List<CustomerInfo> getAllDiscardCustomer() {
		return customerDao.getAllDiscardCustomer();
	}


	@Override
	public int updateAllDiscardCustomer() {
		return customerDao.updateAllDiscardCustomer();
	}


	@Override
	public List<CustomerInfo> getAllwaitForAnchoredList(CustomerInfo info,
			int pageNo, int pageSize) {
		info.setStartsize((pageNo-1)*pageSize);
		info.setEndsize(pageSize);
		List<CustomerInfo> list = customerDao.getAllwaitForAnchoredList(info);
		return list;
	}


	@Override
	public List<CustomerInfo> getCustomerServiceListByParams(CustomerInfo info,
			int pageNo, int pageSize) {
		info.setStartsize((pageNo-1)*pageSize);		
		info.setEndsize(pageSize);
		List<CustomerInfo> list = customerDao.getCustomerServiceListByParams(info);
		return list;
	}
	
	@Override
	public int getAllwaitForAnchoredMoney(CustomerInfo info) {
		return customerDao.getAllwaitForAnchoredMoney(info);
	}


	@Override
	public List<CustomerInfo> getCustomerQualificationInfoList(CustomerInfo cinfo, int pageNo, int pageSize) {
		cinfo.setStartsize((pageNo-1)*pageSize);		
		cinfo.setEndsize(pageSize);
		List<CustomerInfo> list = customerDao.getCustomerQualificationInfoList(cinfo);
		for (CustomerInfo ci : list) {
			ci.setContactsItem(customerContactsDao.getCustomerContactsList(ci.getId()));
			if (ci.getType() == 0) {
				ci.setContractItem(contractDao.selecByCusid(ci.getId()));
			}
		} 
		return list;
	}


	@Override
	public int insertQualificationUser(CustomerQualificationUser cqu) {
		//如果有用户先删除，再新增
		if(cqu.getType()==0) {
			cqu.setIsdel(1);
			customerQualificationUserDao.update(cqu);
		}
		return customerQualificationUserDao.insert(cqu);
	}


	@Override
	public int updateQualificationUser(CustomerQualificationUser cqu) {
		return customerQualificationUserDao.update(cqu);
	}


	@Override
	public CustomerQualificationUser getByParamsQualificationUser(CustomerQualificationUser cqu) {
		return customerQualificationUserDao.getByParams(cqu);
	}


	@Override
	public int insertQualificationItem(CustomerQualificationItem cq) {
		return customerQualificationItemDao.insert(cq);
	}


	@Override
	public int updateQualificationItem(CustomerQualificationItem cq) {
		return customerQualificationItemDao.update(cq);
	}


	@Override
	public CustomerQualificationItem getByParamsQualificationItem(CustomerQualificationItem cq) {
		return customerQualificationItemDao.getByParams(cq);
	}


	@Override
	public List<CustomerQualificationItem> getCustomerQualificationItemList(CustomerQualificationItem cq, int pageNo,
			int pageSize) {
		 cq.setStartsize((pageNo-1)*pageSize);		
		 cq.setEndsize(pageSize);
		List<CustomerQualificationItem> list = customerQualificationItemDao.getCustomerQualificationItemList(cq);
		return list;
	}


	@Override
	public List<CustomerInfo> getCustomerQualificationUserList(CustomerInfo cinfo, int pageNo, int pageSize) {
		cinfo.setStartsize((pageNo-1)*pageSize);		
		cinfo.setEndsize(pageSize);
		List<CustomerInfo> list = customerDao.getCustomerQualificationUserList(cinfo);
		return list;
	}


	@Override
	public int deleteQualificationUser(CustomerQualificationUser cqu) {
		return customerQualificationUserDao.delete(cqu);
	}


	@Override
	public int saveQualificationItem(Long uid,Long cusid, Long contractid, Integer[] itemid, String[] content) {
		int result =0;
		CustomerQualificationItem cq   = new CustomerQualificationItem();
		cq.setCusid(cusid);
		cq.setContractid(contractid);
		cq.setCreateuser(uid);
		cq.setUpdateuser(uid);
		int i =0;
		for(int item:itemid) {
			cq.setItemid(item);
			 //先检查项存不存在，存在判断内容是否相同，不相同则删除旧数据，插入新数据
			CustomerQualificationItem  obj = customerQualificationItemDao.getByItemid(cq);
			if(obj!=null&&obj.getId()!=null) {
				if(!obj.getContent().equals(content[i])) {
					cq.setContent(content[i]);
					CustomerQualificationItem   delobj = new 	CustomerQualificationItem();
					delobj.setId(obj.getId());
					delobj.setIsdel(1);
					customerQualificationItemDao.update(delobj);
					customerQualificationItemDao.insert(cq);
					 result =1;
				} 
			} else {
				 if(StringUtils.isNotEmpty(content[i])) {
					 cq.setContent(content[i]);
					 customerQualificationItemDao.insert(cq);
					 result =1;
				 }
			}
			 i++;
		}
		return result;
	}


	@Override
	public List<CustomerInfo> getQualificationCustomerList(CustomerInfo info, int pageNo, int pageSize) {
		info.setStartsize((pageNo-1)*pageSize);
		info.setEndsize(pageSize);
		return customerDao.getQualificationCustomerList(info);
	}
	@Override
	public List<CustomerInfo> getGaokaoCustomerList(CustomerInfo info, int pageNo, int pageSize){
		info.setStartsize((pageNo-1)*pageSize);
		info.setEndsize(pageSize);
		return customerDao.getGaokaoCustomerList(info);
	}
	@Override
	public int getIdCardCount(CustomerInfo info) {
		return customerDao.getIdCardCount(info);
	}


	@Override
	public Pager getCustomerByBiz(CustomerInfo info, int pageNo, int pageSize) {
		info.setStartsize((pageNo-1)*pageSize);
		info.setEndsize(pageSize);
		List<CustomerInfo> list = customerDao.getCustomerByBiz(info);
		
		/*
		 * for (CustomerInfo ci : list) {
		 * ci.setContactsItem(customerContactsDao.getCustomerContactsList(ci.getId()));
		 * ci.setCategoryItem(customerCategoryDao.getCustomerCategoryListById(ci.getId()
		 * )); }
		 */
		Pager  pager = new Pager();
		pager.setPageNo(pageNo);
		pager.setPageSize(pageSize);
		pager.setResultList(list);
		return pager;
	}


	@Override
	public boolean updateCustomerInfo(CustomerInfo cinfo) {
		if(cinfo.getId()!=null&&cinfo.getId()>0){
			//修改
			cinfo =  customerDao.updateCustomerInfo(cinfo);
		}	
		return true;
	}


}
